from drg_group.yinchuan_2023.Base import message,intersect,SS_VALID
from drg_group.yinchuan_2023.DRG import MDCE_DRG

def group(record):
  adrg_zd=["A15.200x001","A15.201","A15.202","A15.307","A15.602","A15.603","A16.200x002","A16.201","A16.500x004","A16.500x010","A16.501","B49.x14+J99.8*","C34.000x002","C34.000x003","C34.100x003","C34.100x004","C34.101","C34.201","C34.300x003","C34.300x004","C34.301","C34.803","C34.900x001","C34.900x004","C34.900x005","C34.900x006","C34.900x008","C78.000","D02.200x002","D14.300x001","D17.400x004","D18.000x800","D38.100x001","D38.101","D86.000","J18.900","J43.900x001","J43.901","J43.902","J47.x00","J47.x01","J47.x03","J84.101","J84.102","J84.108","J84.900","J85.100","J85.200","J86.000","J86.902","J86.903","J93.100x001","J93.800x001","J93.900","J94.201","J94.802","J96.000","J98.001","J98.011","J98.101","J98.400x001","J98.400x008","J98.400x016","J98.402","J98.404","J98.405","J98.409","J98.411","J98.414","J98.417","Q33.000","Q33.200","Q85.901","R59.009","R91.x00x001","R91.x03","R91.x04","S27.301","S27.302","S27.811"]
  adrg_zd1=[]
  adrg_ss=["32.2000x002","32.2000x003","32.2001","32.2002","32.2003","32.2201","32.2903","32.2905","32.3001","32.3902","32.4100","32.4100x002","32.4101","32.4900x002","32.4902","32.4903","32.5000x001","32.5900x001","32.5901","32.6x00x002","33.3901","33.3902","33.3903","33.4801","33.4802","33.4901","34.0200x003","34.0301","34.0900x011","34.0901","34.0902","34.0904","34.0905","34.0906","34.5100x004","34.5101","34.7301","34.9901","34.9902","34.9904","34.9905"]
  adrg_ss1=[]
  adrg_ss2=[]
  dept_list=[]
  if True and record.zdList[0] in adrg_zd and record.ssList and record.ssList[0] in adrg_ss and record.ssList and intersect(record.ssList,adrg_ss):
    message('符合EB1入组条件，匹配规则：主诊断匹配、主手术匹配、某一手术匹配')
    
    if MDCE_DRG.EB19_group(record):
      return 'EB19'

    return 'EB1'
  else:
    return ''

